package com.li.service;


import com.li.mapper.TeacherMapper;
import com.li.pojo.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherService {
    @Autowired
    TeacherMapper teacherMapper;

    public Teacher queryTeacher(Teacher teacher){
        return teacherMapper.queryTeacher(teacher);
    }

    public boolean addTeacher(Teacher teacher){
        if(teacherMapper.queryTeacherByTno(teacher)==null){
            teacherMapper.insertTeacher(teacher);
            return  true;
        }
        return false;
    }

    public boolean deleteTeacher(Teacher teacher){
        if(teacherMapper.queryTeacherByTno(teacher)!=null){
            teacherMapper.deleteTeacher(teacher);
            return true;
        }
        return false;
    }
    public boolean updateTeacher(Teacher teacher){
        teacherMapper.updateTeacher(teacher);
        return  true;
    }
    public List<Teacher> allTeacher(){
        return teacherMapper.listTeacher();
    }
}
